using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
	
    public class FilterInfo
    {
		#region Local Variable
		public enum Field
		{			
			VALUE,
			Description
		}
		private String _VALUE;
		private String _Description;
		
		public String VALUE{	get{ return _VALUE;} set{_VALUE = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public FilterInfo()
		{			
			_VALUE = "";			
			_Description = "";
		}
		public FilterInfo(
		
		String VALUE,
		String Description
		)
		{			
			_VALUE = VALUE;
			_Description = Description;
		}
		public FilterInfo(DataRow dr)
		{
			if (dr != null)
			{
				_VALUE = dr[Field.VALUE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUE.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);				
			}
		}
		public FilterInfo(DataRowView dr)
		{
			if (dr != null)
			{
				
				_VALUE = dr[Field.VALUE.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.VALUE.ToString()]);				
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
			}
		}
		public FilterInfo(FilterInfo objEntr)
		{			
			
			_VALUE = objEntr.VALUE;		
			_Description = objEntr.Description;	
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TVC_LOOKUPHVJ");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.VALUE.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String))
			});
			return dt;
		}
        public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();			
			row[Field.VALUE.ToString()] = _VALUE;
			row[Field.Description.ToString()] = _Description;
			return row;
		}
        #endregion InitTable
    }
}
